import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
const r_index =()=>import('views/index/index.vue')
  const routes = [
    { path: '/', component: r_index, meta: { title: '马蜂窝-首页' } },
    { path: '/mdd', component: ()=>import('views/Mdd/mdd.vue'), meta: { title: '马蜂窝-目的地' } },
    { 
      path: '/gonglve', 
      component: ()=>import('views/gonglve/gonglve.vue'),
      children: [
        { path: '', component: ()=>import('components/gonglve/gl_index.vue'), meta: { title: '马蜂窝-旅游攻略' } },
        { path: 'item', component: ()=>import('components/gonglve/gl_tjgl_item.vue'), meta: { title: '马蜂窝-详细攻略' } }
      ] 
    },
    { path: '/flight', component: ()=>import('views/flight/flight.vue'), meta: { title: '马蜂窝-机票火车票' } },
    { path: '/hotel', component: ()=>import('views/hotel/hotel.vue'), meta: { title: '马蜂窝-订酒店' } },
    { path: '/sales', component: ()=>import('views/sales/index.vue'), meta: { title: '马蜂窝-自由行' } },
    { path: '/wenda', component:  ()=>import('views/community/wenda.vue'), meta: { title: '马蜂窝-问答' } }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next) => {
	if(to.meta.title) {
		document.title = to.meta.title
	}
	next()
})

export default router
